package uz.rt.dicom.data.element;

import uz.rt.dicom.ValueRepresentation;
import uz.rt.dicom.data.StringElement;
import uz.rt.dicom.io.DicomIOException;
import uz.rt.dicom.io.DicomInputStream;
import uz.rt.dicom.tag.DicomTag;

import java.io.IOException;

public class OtherWordString extends StringElement implements Comparable<OtherWordString>
{
// --------------------------- CONSTRUCTORS ---------------------------

    public OtherWordString(DicomTag tag)
    {
        super(tag);
    }

// ------------------------ INTERFACE METHODS ------------------------


// --------------------- Interface Comparable ---------------------


    public int compareTo(OtherWordString o)
    {
        if (!tag.equals(o.getTag())) return tag.compareTo(o.getTag());
        if (!vm.equals(o.getVm())) return vm.compareTo(o.getVm());
        return value.compareTo(o.getValue());
    }

// --------------------- Interface IDataElement ---------------------

    @Override
    public byte[] getVR()
    {
        return ValueRepresentation.OW;
    }

    @Override
    public ValueRepresentation getValueRepresentation()
    {
        return ValueRepresentation.OtherWordString;
    }

    public void read(DicomInputStream dicomInputStream, int length) throws IOException
    {
        // skip it since we 'll never use it
        if (dicomInputStream.skip(length) != length)
            throw new DicomIOException(
                    "Number of bytes skipped in the dicom input stream differs from the expected number of bytes.");
    }
}
